﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Windows.Forms;
using SMALLERP.ComClass;
using SMALLERP.DataClass;
using SMALLERP.PO;
using ThoughtWorks.QRCode.Codec;
using SMALLERP;


namespace XJLSC.QM
{
    public partial class SCKC : Form
    {   
        private readonly DataBase db = new DataBase();
        public delegate void Cdgzzx(object sender, EventArgs e);
        //定义委托对象
        public Cdgzzx cdgzzx;
        
        public SCKC()
        {
            InitializeComponent();
        }

        public string UserId
        {
            get
            {
                return _UserId;
            }
        }
        string _UserId;


        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName
        {
            get
            {
                return _UserName;
            }
        }
        string _UserName;

        public event EventHandler DataSelected;
        private void SCKC_Load(object sender, EventArgs e)
        {
            string strSql = null;
            if (SCGY.gzzx != "仓库开窗")
            {
                strSql = "SELECT RTRIM(MX001) 设备编号,RTRIM(MX003) 设备名称 FROM CMSMX WHERE MX002='" + SCGY.gzzx + "'";
            }
            else
            { 
               strSql = "SELECT RTRIM(MC001) 仓库编号,RTRIM(MC002) 仓库名称 FROM CMSMC";
            }
            try
            {
                dataGridView1.DataSource = db.GetDataSet1(strSql, "CMSMX").Tables["CMSMX"];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "软件提示");
                throw ex;
            }
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            

        }

        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
           
        }

        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.DataSelected != null)
            {
                if (SCGY.gzzx != "仓库开窗")
                {
                    this._UserId = dataGridView1.Rows[e.RowIndex].Cells["设备编号"].Value.ToString();
                    this._UserName = dataGridView1.Rows[e.RowIndex].Cells["设备名称"].Value.ToString();
                }
                else
                {
                    this._UserId = dataGridView1.Rows[e.RowIndex].Cells["仓库编号"].Value.ToString();
                    this._UserName = dataGridView1.Rows[e.RowIndex].Cells["仓库名称"].Value.ToString();
                }
                // 引发事件
                this.DataSelected(null, null);
            }
            this.Close();  // 关闭本窗体

        }

       
    }
}
